<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>注册页面</title>
    <!--    引入格式文件-->
    
    <link rel="stylesheet" href="./css/reg.css" />
  </head>
  <body>
    <style></style>
    <div class="rg_layout">
      <div class="rg_left">
        <p>新用户注册</p>
        <p>USER REGISTER</p>
      </div>
      <div class="rg_center">
        <div class="rg_form">
          <form action="#" method="post" id="form">
            <table>
              <tr>
                <td class="td_left"><label for="username">用户名</label></td>
                <td class="td_right">
                  <input type="text" id="username" name="username">
                </td>
              </tr>
              <tr>
                <td class="td_left"><label for="password">密码</label></td>
                <td class="td_right">
                  <input type="password" id="password" name="password">
                </td>
              </tr>
              <tr>
                <td class="td_left"><label for="phone">手机号</label></td>
                <td class="td_right">
                  <input type="text" id="phone" name="phone">
                </td>
              </tr>
              <tr>
                <td class="td_left"><label for="">性别</label></td>
                <td class="td_right" id="sex">
                  <label>
                    <input type="radio" value="1" name="sex" checked/>男
                  </label>&nbsp;&nbsp;&nbsp;
                  <label>
                    <input type="radio" value="0" name="sex">女
                  </label>
                </td>
              </tr>
              <tr>
                <td class="td_left"><label for="">是否VIP</label></td>
                <td class="td_right" id="vip">
                  <label><input type="radio"  value="1" name="vip">是
                  </label>&nbsp;&nbsp;&nbsp;
                  <label>
                    <input type="radio" value="0" name="vip" checked/>否
                  </label>
                </td>
              </tr>
              <tr>
                <td class="td_left"><label for="question">密保问题</label></td>
                <td class="td_right">
                  <input type="text" id="question" name="question">
                </td>
              </tr>
              <tr>
                <td class="td_left"><label for="answer">密保答案</label></td>
                <td class="td_right">
                  <input type="text" id="answer" name="answer">
                </td>
              </tr>
              <tr>
                <td class="td_left"><label for="avatar">头像</label></td>
                <td class="td_right">
                  <input type="text" id="avatar" disabled name="avatar">
                  <button>选择图片</button><input type="file" hidden id="file1" name="">
                </td>
              </tr>
              <tr>
                <td colspan="2" align="center">
                  <input type="submit" name="" value="立即注册" id="btn_sub">
                </td>
              </tr>
            </table>
          </form>
        </div>
      </div>
      <div class="rg_right">
        <p>已有账号？<a href="#">立即登录</a></p>
      </div>
    </div>


    <script src="/jquery.min.js"></script>
  <script src="/axios.js"></script>
  <script src="/dizhi.js"></script>
  <script>

$(function(){
  

  $('#btn_sub').on('click',async function(e){
    e.preventDefault()
    const sex = +$("input[name='sex']:checked").val()
  const vip = +$("input[name='vip']:checked").val()
    console.log($('#username').val() ); 
 const {data:{data}}= await axios({
    url:'/user/reg',
    method:'POST',
    data:{
      username:$('#username').val(),
      password:$('#password').val(),
      phone: $('#phone').val(),
      question: $('#question').val(),
      answer: $('#answer').val(),
      sex,
      vip
    }
  })
  location.href='/01-loginBaseCode/login.html'
  })







})


       
  </script>
  </body>
  
</html>
